﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string s = "Server=.\\sqlexpress;DataBase=Teacher;Uid=sa;PWD=sa";
        SqlConnection con = new SqlConnection(s);
       
        con.Open();
        string strsql = "select * from studentinfo";
        SqlDataAdapter adapter = new SqlDataAdapter(strsql, con);
        DataSet ds = new DataSet();
        adapter.Fill(ds, "studentinfo");
        ReportDocument studentReport = new ReportDocument();
        studentReport.Load(Server.MapPath("CrystalReport.rpt"));
        studentReport.SetDataSource(ds);
        this.CrystalReportViewer1.ReportSource = studentReport;
    }
}